<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>ckeditor5编译器使用</title>
    <script src="https://cdn.ckeditor.com/ckeditor5/31.0.0/decoupled-document/ckeditor.js"></script>
</head>
<body>
<h3>自定义菜单栏的ckeditor5编译器初始化</h3>
    <div class="row cl">
            <div class="formControls col-xs-6 col-sm-6">
               <textarea name="subject" id="ckeditor1"></textarea>
            </div>
        </div>
		<!--ckeditor5默认编辑器的高度-->
        <style>
            .ck-editor__editable {
                min-height: 100px;
            }
        </style>
        <script>
            ClassicEditor.create( ckeditor1,{
            toolbar: ['imageUpload','link'],
                        ckfinder: {
                            uploadUrl : '/admin/Upload/uploadImages?command=QuickUpload&type=Files&responseType=json'
							//后端处理上传逻辑返回json数据,包括uploaded(选项true/false)和url两个字段
                        }
                    }).then(
            ).catch()
        </script>
<h3>默认菜单栏的ckeditor5编译器初始化</h3>
		<div class="row cl">
            <div class="formControls col-xs-6 col-sm-6">
                <textarea name="description" id="ckeditor2"></textarea>
            </div>
        </div>
        <script>
            ClassicEditor.create( ckeditor2,{
                ckfinder: {
                    uploadUrl : '/admin/Upload/uploadImages?command=QuickUpload&type=Files&responseType=json'
					//后端处理上传逻辑返回json数据,包括uploaded(选项true/false)和url两个字段
                }
            }).then(
            ).catch()
        </script>
	<!--/**
     * 图片上传 written :yangxingyi 2018-06-06 15:35 (ps,这是tp5的上传图片写法,其他编辑器的按要求写即可)
     */
    public function uploadImages($path=false,$save=false){
        $file = request()->file('upload');
        $path = $path?$path:ROOT_PATH . 'public/tmp/uploads/';
        $save = $save?$save:SITE_URL.'/tmp/uploads/';
        if($file){
            $info = $file->move($path);
            if($info){
                $url = $save.$info->getSaveName();// 成功上传后 获取上传信息
            }else{
                //$error = $file->getError();
            }
        }
        $url = str_replace("\\","/",$url);//把url的\换成/
       return json(['uploaded'=>true,'url'=>$url]);
    }-->
</body>
</html>
